#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Instruments/Bond.h>
#pragma unmanaged 
#include <ql\instruments\bonds\cmsratebond.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Times;
using namespace Cephei::QL::Indexes;
using namespace Cephei::QL;
using namespace Cephei::QL::Instruments;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Instruments { namespace Bonds {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of ICmsRateBond
	public ref class CCmsRateBond : 
            public CBond,
            public Cephei::QL::Instruments::Bonds::ICmsRateBond
	{
	protected: 
		boost::shared_ptr<QuantLib::CmsRateBond>* _ppCmsRateBond;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CmsRateBond>* _phCmsRateBond;
#endif
		Object^ _CmsRateBondOwner;     // reference to object that manages the storage for this object
	internal:
		CCmsRateBond (UInt32 settlementDays, Double faceAmount, Cephei::QL::Times::ISchedule^ schedule, Cephei::QL::Indexes::ISwapIndex^ index, Cephei::QL::Times::IDayCounter^ paymentDayCounter, Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>^ paymentConvention, Microsoft::FSharp::Core::FSharpOption<UInt32>^ fixingDays, Microsoft::FSharp::Core::FSharpOption<Cephei::IVector<Double>^>^ gearings, Microsoft::FSharp::Core::FSharpOption<Cephei::IVector<Double>^>^ spreads, Microsoft::FSharp::Core::FSharpOption<Cephei::IVector<Double>^>^ caps, Microsoft::FSharp::Core::FSharpOption<Cephei::IVector<Double>^>^ floors, Microsoft::FSharp::Core::FSharpOption<Boolean>^ inArrears, Microsoft::FSharp::Core::FSharpOption<Double>^ redemption, Microsoft::FSharp::Core::FSharpOption<DateTime>^ issueDate, Cephei::QL::IPricingEngine^ QL_Pricer);
        CCmsRateBond (boost::shared_ptr<QuantLib::CmsRateBond>& childNative, Object^ owner);
        CCmsRateBond (QuantLib::CmsRateBond& childNative, Object^ owner);
        CCmsRateBond (CCmsRateBond^ copy);
        CCmsRateBond (System::Type^ t);
#ifdef STRUCT
        CCmsRateBond (QuantLib::CmsRateBond childNative);
#endif       
#ifdef HANDLE
		CCmsRateBond (QuantLib::Handle<QuantLib::CmsRateBond>& childNative, Object^ owner);
		CCmsRateBond (QuantLib::Handle<QuantLib::CmsRateBond> childNative);
#endif
		virtual ~CCmsRateBond ();
		!CCmsRateBond ();

	internal:
		QuantLib::CmsRateBond& GetReference ();
		boost::shared_ptr<QuantLib::CmsRateBond>& GetShared ();
		QuantLib::CmsRateBond* GetPointer ();
        void SetCmsRateBond (boost::shared_ptr<QuantLib::CmsRateBond> native)
        {
            if (_ppCmsRateBond != NULL)
                delete _ppCmsRateBond;
            _ppCmsRateBond = new boost::shared_ptr<QuantLib::CmsRateBond> (native);
            SetBond (boost::dynamic_pointer_cast<QuantLib::Bond> (*_ppCmsRateBond));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CmsRateBond>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CCmsRateBond_Factory : public System::MarshalByRefObject,  public ICmsRateBond_Factory
	{
	public:
        virtual ICmsRateBond^ Create (UInt32 settlementDays, Double faceAmount, Cephei::QL::Times::ISchedule^ schedule, Cephei::QL::Indexes::ISwapIndex^ index, Cephei::QL::Times::IDayCounter^ paymentDayCounter, Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>^ paymentConvention, Microsoft::FSharp::Core::FSharpOption<UInt32>^ fixingDays, Microsoft::FSharp::Core::FSharpOption<Cephei::IVector<Double>^>^ gearings, Microsoft::FSharp::Core::FSharpOption<Cephei::IVector<Double>^>^ spreads, Microsoft::FSharp::Core::FSharpOption<Cephei::IVector<Double>^>^ caps, Microsoft::FSharp::Core::FSharpOption<Cephei::IVector<Double>^>^ floors, Microsoft::FSharp::Core::FSharpOption<Boolean>^ inArrears, Microsoft::FSharp::Core::FSharpOption<Double>^ redemption, Microsoft::FSharp::Core::FSharpOption<DateTime>^ issueDate, Cephei::QL::IPricingEngine^ QL_Pricer);
    };
   
/*Cephei*/ } /*QL*/ } /*Instruments*/ } /*Bonds */}
